package com.sl.au.repository;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.sl.au.entity.Account;
import com.sl.au.entity.Option;
import com.sl.au.entity.User;
import com.sl.au.entity.WarnStatus;

public interface WarnStatusRepository extends JpaRepository<WarnStatus, String> {
	
	@Query(" select o from WarnStatus o where o.warnStatusName like %?1% or o.warnStatus like %?1% or o.partsType.parts_type like %?1% or o.partsType.parts_name like %?1% ")
	Page<WarnStatus> getByKey(String key, Pageable pageable);
	
	@Query(" select count(*) as num from WarnStatus o ")
	int getCountAll();

	@Query(" select count(*) as num from WarnStatus o where o.warnStatusName like %?1% or o.warnStatus like %?1% or o.partsType.parts_type like %?1% or o.partsType.parts_name like %?1% ")
	int getCountByKey(String key);
	
	@Query(" select o from WarnStatus o where o.partsType.parts_type = ?1 and  o.warnStatus = ?2 ")
	WarnStatus getByPartsTypeAndWarnStatus(String partsType, String warnStatus);
}